package com.codingvip.concurrent;

import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;

/**
 * @author hansongtao
 */
public class DelayQueueExample {

    public static void main(String[] args) {
        DelayQueue queue = new DelayQueue();

        Delayed element1 = new DelayedElement("name1",5000);

        queue.put(element1);

        try {
            DelayedElement element2 = (DelayedElement) queue.take();
            System.out.println(element2.toString());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}